home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / Serial.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  9.1 KB  |  251 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Serial.p
  3.  
  4.      Contains:    Asynchronous Serial Driver (.AIn/.AOut/.BIn/.BOut) Interfaces
  5.  
  6.      Version:    Technology:    System 7.6+
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT Serial;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __SERIAL__}
  27. {$SETC __SERIAL__ := 1}
  28.  
  29. {$I+}
  30. {$SETC SerialIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36.  
  37.  
  38. {$PUSH}
  39. {$ALIGN MAC68K}
  40. {$LibExport+}
  41.  
  42.  
  43. CONST
  44.     baud150                        = 763;
  45.     baud300                        = 380;
  46.     baud600                        = 189;
  47.     baud1200                    = 94;
  48.     baud1800                    = 62;
  49.     baud2400                    = 46;
  50.     baud3600                    = 30;
  51.     baud4800                    = 22;
  52.     baud7200                    = 14;
  53.     baud9600                    = 10;
  54.     baud14400                    = 6;
  55.     baud19200                    = 4;
  56.     baud28800                    = 2;
  57.     baud38400                    = 1;
  58.     baud57600                    = 0;
  59.  
  60.     stop10                        = 16384;
  61.     stop15                        = -32768;
  62.     stop20                        = -16384;
  63.  
  64.     noParity                    = 0;
  65.     oddParity                    = 4096;
  66.     evenParity                    = 12288;
  67.  
  68.     data5                        = 0;
  69.     data6                        = 2048;
  70.     data7                        = 1024;
  71.     data8                        = 3072;
  72.  
  73.     aData                        = 6;                            {  channel A data in or out (historical)  }
  74.     aCtl                        = 2;                            {  channel A control (historical)  }
  75.     bData                        = 4;                            {  channel B data in or out (historical)  }
  76.     bCtl                        = 0;                            {  channel B control (historical)  }
  77.  
  78.     dsrEvent                    = 2;                            {  flag for SerShk.evts  }
  79.     riEvent                        = 4;                            {  flag for SerShk.evts  }
  80.     dcdEvent                    = 8;                            {  flag for SerShk.evts  }
  81.     ctsEvent                    = 32;                            {  flag for SerShk.evts  }
  82.     breakEvent                    = 128;                            {  flag for SerShk.evts  }
  83.  
  84.     xOffWasSent                    = 128;                            {  flag for SerStaRec.xOffSent  }
  85.     dtrNegated                    = 64;                            {  flag for SerStaRec.xOffSent  }
  86.     rtsNegated                    = 32;                            {  flag for SerStaRec.xOffSent  }
  87.  
  88.     ainRefNum                    = -6;                            {  serial port A input  }
  89.     aoutRefNum                    = -7;                            {  serial port A output  }
  90.     binRefNum                    = -8;                            {  serial port B input  }
  91.     boutRefNum                    = -9;                            {  serial port B output  }
  92.  
  93.     swOverrunErr                = 1;                            {  serial driver error masks  }
  94.     breakErr                    = 8;                            {  serial driver error masks  }
  95.     parityErr                    = 16;                            {  serial driver error masks  }
  96.     hwOverrunErr                = 32;                            {  serial driver error masks  }
  97.     framingErr                    = 64;                            {  serial driver error masks  }
  98.  
  99.     kOptionPreserveDTR            = 128;                            {  option bit used with Control code 16  }
  100.     kOptionClockX1CTS            = 64;                            {  option bit used with Control code 16  }
  101.  
  102.     kUseCTSOutputFlowControl    = 128;                            {  flag for SerShk.fCTS  }
  103.     kUseDSROutputFlowControl    = 64;                            {  flag for SerShk.fCTS  }
  104.     kUseRTSInputFlowControl        = 128;                            {  flag for SerShk.fDTR  }
  105.     kUseDTRInputFlowControl        = 64;                            {  flag for SerShk.fDTR  }
  106.  
  107.     sPortA                        = 0;                            {  Macintosh modem port  }
  108.     sPortB                        = 1;                            {  Macintosh printer port  }
  109.     sCOM1                        = 2;                            {  RS-232 port COM1  }
  110.     sCOM2                        = 3;                            {  RS-232 port COM2  }
  111.  
  112.  
  113. TYPE
  114.     SPortSel                            = SInt8;
  115. { csCodes for serial driver Control routines }
  116.  
  117. CONST
  118.     kSERDConfiguration            = 8;                            {  program port speed, bits/char, parity, and stop bits  }
  119.     kSERDInputBuffer            = 9;                            {  set buffer for chars received with no read pending  }
  120.     kSERDSerHShake                = 10;                            {  equivalent to SerHShake, largely obsolete  }
  121.     kSERDClearBreak                = 11;                            {  assert break signal on output  }
  122.     kSERDSetBreak                = 12;                            {  negate break state on output  }
  123.     kSERDBaudRate                = 13;                            {  set explicit baud rate, other settings unchanged  }
  124.     kSERDHandshake                = 14;                            {  superset of 10, honors setting of fDTR  }
  125.     kSERDClockMIDI                = 15;                            {  clock externally on CTS with specified multiplier  }
  126.     kSERDMiscOptions            = 16;                            {  select clock source and DTR behavior on close  }
  127.     kSERDAssertDTR                = 17;                            {  assert DTR output  }
  128.     kSERDNegateDTR                = 18;                            {  negate DTR output  }
  129.     kSERDSetPEChar                = 19;                            {  select char to replace chars with invalid parity  }
  130.     kSERDSetPEAltChar            = 20;                            {  select char to replace char that replaces chars with invalid parity  }
  131.     kSERDSetXOffFlag            = 21;                            {  set XOff output flow control (same as receiving XOff)  }
  132.     kSERDClearXOffFlag            = 22;                            {  clear XOff output flow control (same as receiving XOn)  }
  133.     kSERDSendXOn                = 23;                            {  send XOn if input flow control state is XOff  }
  134.     kSERDSendXOnOut                = 24;                            {  send XOn regardless of input flow control state  }
  135.     kSERDSendXOff                = 25;                            {  send XOff if input flow control state is XOn  }
  136.     kSERDSendXOffOut            = 26;                            {  send XOff regardless of input flow control state  }
  137.     kSERDResetChannel            = 27;                            {  reset serial I/O channel hardware  }
  138.     kSERDHandshakeRS232            = 28;                            {  extension of 14, allows full RS-232 hardware handshaking  }
  139.     kSERDStickParity            = 29;                            {  use mark/space parity  }
  140.     kSERDAssertRTS                = 30;                            {  assert RTS output  }
  141.     kSERDNegateRTS                = 31;                            {  negate RTS output  }
  142.     kSERD115KBaud                = 115;                            {  set 115.2K baud data rate  }
  143.     kSERD230KBaud                = 230;                            {  set 230.4K baud data rate  }
  144.  
  145.  
  146. { csCodes for serial driver Status routines }
  147.     kSERDInputCount                = 2;                            {  return characters available (SerGetBuf)  }
  148.     kSERDStatus                    = 8;                            {  return characters available (SerStatus)  }
  149.     kSERDVersion                = 9;                            {  return version number in first byte of csParam  }
  150.     kSERDGetDCD                    = 256;                            {  get instantaneous state of DCD (GPi)  }
  151.  
  152.  
  153.  
  154. TYPE
  155.     SerShkPtr = ^SerShk;
  156.     SerShk = PACKED RECORD
  157.         fXOn:                    Byte;                                    {  XOn/XOff output flow control flag  }
  158.         fCTS:                    Byte;                                    {  hardware output flow control flags  }
  159.         xOn:                    UInt8;                                    {  XOn character  }
  160.         xOff:                    UInt8;                                    {  XOff character  }
  161.         errs:                    Byte;                                    {  errors mask bits  }
  162.         evts:                    Byte;                                    {  event enable mask bits  }
  163.         fInX:                    Byte;                                    {  XOn/XOff input flow control flag  }
  164.         fDTR:                    Byte;                                    {  hardware input flow control flags  }
  165.     END;
  166.  
  167.     SerStaRecPtr = ^SerStaRec;
  168.     SerStaRec = PACKED RECORD
  169.         cumErrs:                Byte;                                    {  errors accumulated since last SerStatus() call  }
  170.         xOffSent:                Byte;                                    {  input (requested to be) held off by xOffWasSent or dtrNegated or rtsNegated  }
  171.         rdPend:                    Byte;                                    {  incomplete read pending in I/O queue  }
  172.         wrPend:                    Byte;                                    {  incomplete write pending in I/O queue  }
  173.         ctsHold:                Byte;                                    {  transmit disabled by hardware handshaking  }
  174.         xOffHold:                Byte;                                    {  transmit disabled by XOn/XOff handshaking  }
  175.         dsrHold:                Byte;                                    {  transmit disabled: external device not ready  }
  176.         modemStatus:            Byte;                                    {  reports modem status according to SerShk.evts  }
  177.     END;
  178.  
  179. {$IFC OLDROUTINENAMES }
  180. { ********************************************************************************************* }
  181. { The following constant names have been retired in favor of standard, more descriptive names.  }
  182. { You can still compile old code by defining OLDROUTINENAMES. There were several constants that }
  183. { were formerly available that have been removed, as they are now regarded as either private or }
  184. { unsupported. We advise that you stop using any constants that are not defined in this file.   }
  185. { ********************************************************************************************* }
  186.  
  187. CONST
  188.     serdOptionClockExternal        = 64;                            {  option bit used with Control code 16  }
  189.     serdOptionPreserveDTR        = 128;                            {  option bit used with Control code 16  }
  190.  
  191. { csCodes for serial driver Control routines }
  192.     serdReset                    = 8;
  193.     serdSetBuf                    = 9;
  194.     serdHShake                    = 10;
  195.     serdClrBrk                    = 11;
  196.     serdSetBrk                    = 12;
  197.     serdSetBaud                    = 13;
  198.     serdHShakeDTR                = 14;
  199.     serdSetMIDI                    = 15;
  200.     serdSetMisc                    = 16;
  201.     serdSetDTR                    = 17;
  202.     serdClrDTR                    = 18;
  203.     serdSetPEChar                = 19;
  204.     serdSetPECharAlternate        = 20;
  205.     serdSetXOff                    = 21;
  206.     serdClrXOff                    = 22;
  207.     serdSendXOnConditional        = 23;
  208.     serdSendXOn                    = 24;
  209.     serdSendXOffConditional        = 25;
  210.     serdSendXOff                = 26;
  211.     serdChannelReset            = 27;
  212.     serdSet230KBaud                = 230;                            {  set 230K baud data rate  }
  213.  
  214.  
  215. { csCodes for serial driver Status routines }
  216.     serdGetBuf                    = 2;
  217.     serdStatus                    = 8;
  218.     serdGetVers                    = 9;
  219.  
  220. {$ENDC}  {OLDROUTINENAMES}
  221.  
  222. {
  223.     The following interfaces are for the legacy high-level serial driver glue in
  224.     the interface libraries of your development system. They merely substitue for
  225.     the corresponding synchronous calls to PBControl and PBStatus.
  226.  
  227.     They have not been updated as the serial driver API has evolved. Take note:
  228.  
  229.         SerHShake does not support hardware input flow control. Use csCode 14.
  230.         SerStatus returns only the first six bytes of SerStaRec (through xOffHold).
  231. }
  232. FUNCTION SerReset(refNum: INTEGER; serConfig: INTEGER): OSErr;
  233. FUNCTION SerSetBuf(refNum: INTEGER; serBPtr: Ptr; serBLen: INTEGER): OSErr;
  234. FUNCTION SerHShake(refNum: INTEGER; {CONST}VAR flags: SerShk): OSErr;
  235. FUNCTION SerSetBrk(refNum: INTEGER): OSErr;
  236. FUNCTION SerClrBrk(refNum: INTEGER): OSErr;
  237. FUNCTION SerGetBuf(refNum: INTEGER; VAR count: LONGINT): OSErr;
  238. FUNCTION SerStatus(refNum: INTEGER; VAR serSta: SerStaRec): OSErr;
  239.  
  240.  
  241. {$ALIGN RESET}
  242. {$POP}
  243.  
  244. {$SETC UsingIncludes := SerialIncludes}
  245.  
  246. {$ENDC} {__SERIAL__}
  247.  
  248. {$IFC NOT UsingIncludes}
  249.  END.
  250. {$ENDC}
  251.